#include "src/antistress.h"

#include <QtGui>
#include <QApplication>
#include "src/usbsensor.h"
#include "src/analyser.h"
#include "src/sensorplot.h"
#include <QDebug>

int main(int argc, char *argv[]) {

	QApplication a(argc, argv);

	int sensors = 1;
	int fftPoints = 30;
	int logFolder = 0;

	sensorPlot plot;//Not used

	// initialize the controller
	Analyser* pAnalyser = new Analyser(fftPoints);
	pAnalyser->setView(&plot);




	//Detect accelerometre
	vector<UsbSensor*> sensorList;
	// Sensor fixed number
	for (int i = 0; i < sensors; i++) {
		char devName[256];
		sprintf(devName, "/dev/usb/hiddev%d", i);
		UsbSensor* pSensor = new UsbSensor();
		pSensor->initSensor(devName);
		pSensor->startCapture();
		pAnalyser->addSensor(pSensor);
		sensorList.push_back(pSensor);
	}

	plot.show();
	// initialize the view
//	antistress w;
//	w.show();


	getchar();

	int ret = a.exec();
	// terminate all
//	delete pAnalyser;
	for (unsigned int i = 0; i < sensorList.size(); i++) {
		sensorList[i]->stop();
		delete sensorList[i];
	}




	return ret;
}
